include('shared.lua')

ENT.RenderGroup 		= RENDERGROUP_BOTH
function ENT:Initialize()
	self.Lua=""
	self.Confirmed=false
	self.PrevOuts={}
	self.pl=LocalPlayer()
end

function ENT:Draw()
	self.BaseClass.Draw(self)
    Wire_Render(self.Entity)
	//This allows hooks to entnameDraw
	if(self.DrawFunc) then
		self.DrawFunc(self)
	end
end

function ENT:Think()
	//This allows hooks to entnameThink
	if(self.Name) then
		//Check for changes
		if(self.ThinkFunc) then
			self.ThinkFunc(self)
		end
		for output,value in pairs(WireClua.Outs[self.Name] or {}) do
			if(tonumber(value)==nil) then
				self.PrevOuts[output]=0
				WireClua.Outs[self.Name][output]=0
				value=0
			end
			if(value!=self.PrevOuts[output]) then
				WireClua.Send(self.Name,output,value)
				self.PrevOuts[output]=value
			end
		end
	end
end

function ENT:OnRemove()
	if(self.Name) then
		WireClua.Ents[self.Name]=nil
		WireClua.Ins[self.Name]=nil
		WireClua.Outs[self.Name]=nil
	end
end

function ENT:ReloadLua()
	if(self.Lua!="") then
		if(self.Confirmed==false) then
			WireClua.ConfirmLua(self,self.Lua)
			return
		else
			RunString(self.Lua)
			return
		end
	end
end
function ENT:SetLua(lua)
	self.Confirmed=false
	self.Lua=lua
	self:ReloadLua()
end